package model.entity.product;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name = "Theme")
public class Theme {

	private int themeId;
	private String name;
	private String image;
	private String description;
	private Set<Product> products = new HashSet<Product>(0);

	public Theme() {
	}

	public Theme(String name) {
		this.name = name;
	}

	public Theme(String name, String image, String description,
			Set<Product> products) {
		this.name = name;
		this.image = image;
		this.description = description;
		this.products = products;
	}

	@Id
	@GeneratedValue(generator = "Theme_ID_Gen", strategy = GenerationType.IDENTITY)
	@SequenceGenerator(name = "Theme_ID_Gen", sequenceName = "Theme_SEQ_ID")
	@Column(name = "ThemeID", unique = true, nullable = false)
	public int getThemeId() {
		return this.themeId;
	}

	public void setThemeId(int themeId) {
		this.themeId = themeId;
	}

	@Column(name = "Name", nullable = false)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "Image")
	public String getImage() {
		return this.image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	@Column(name = "Description")
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinTable(name = "ProductTheme", joinColumns = { @JoinColumn(name = "ThemeID") }, inverseJoinColumns = { @JoinColumn(name = "ProductID") })
//	@JoinTable(name = "ProductTheme")
	public Set<Product> getProducts() {
		return this.products;
	}

	public void setProducts(Set<Product> products) {
		this.products = products;
	}

}
